import 'package:flutter/material.dart';

class Flutter_AnimatedWidget_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Flutter_AnimatedWidget_State();
  }
}

class Flutter_AnimatedWidget_State extends State<Flutter_AnimatedWidget_Page>
    with SingleTickerProviderStateMixin {
  Animation<double> animation;
  AnimationController controller;

  @override
  void initState() {
    super.initState();
    controller = AnimationController(
        vsync: this, duration: Duration(milliseconds: 2000));
    animation = Tween(begin: 0.0, end: 300.0).animate(controller);
    controller.forward();
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedLogo(animation: animation);
  }

}
/**
 * AnimatedWidget助手类替代addListener()和setState()
 */
class AnimatedLogo extends AnimatedWidget {

  AnimatedLogo({Key key, Animation<double> animation})
      :super(key: key, listenable: animation);

  @override
  Widget build(BuildContext context) {
    Animation<double> animation = listenable;
    return Center(
      child: Container(
        color: Colors.white,
        width: animation.value,
        height: animation.value,
        child: FlutterLogo(),
      ),
    );
  }

}